<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="/struts-tags" prefix="s" %>

<%//用于实现jsp模板的继承关系,请查看:http://code.google.com/p/rapid-framework/wiki/rapid_jsp_extends %>
<%@ taglib uri="http://www.rapid-framework.org.cn/rapid" prefix="rapid" %>

<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <title>附近回收箱</title>
    <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <title>Title</title>
    <link rel="stylesheet" href="//res.wx.qq.com/open/libs/weui/1.1.3/weui.min.css">
</head>
<body>


<div class="weui-panel weui-panel_access">
    <div class="weui-panel__hd" id="locationShow">您当前的位置：定位中。。。</div>
    <div class="weui-panel__bd">
        <c:forEach items="${bins}" var="bin">
        <a href="javascript:"  locationInfo="${bin.gpsInfo}" class="weui-media-box weui-media-box_appmsg">
            <div class="weui-media-box__hd">
                <img class="weui-media-box__thumb" src="${ctxPath}/assets/common/images/location.jpg"/>
            </div>
            <div class="weui-media-box__bd">
                <h4 class="weui-media-box__title">${bin.name}</h4>
                <p class="weui-media-box__desc">${bin.area}${bin.address}</p>
            </div>
            <div class="weui-cell__ft">导航&nbsp;&gt;</div>
        </a>
        </c:forEach>

    </div>
</div>
</body>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=3.0&ak=k6hUNlqyGNy0xyK60Un9hpFe2a8Fxch1">
</script>
<script src="https://cdn.staticfile.org/zepto/1.2.0/zepto.min.js"></script>
<script>
    var fromLocation = "";
    $(function(){
        var geolocation = new BMap.Geolocation();
        geolocation.enableSDKLocation();
        geolocation.getCurrentPosition(function(r){
            if(this.getStatus() == BMAP_STATUS_SUCCESS){
                //alert('您的位置：'+r.point.lng+','+r.point.lat);
                fromLocation = r.point.lng+","+r.point.lat;
                var myGeo = new BMap.Geocoder({extensions_town: true});
                myGeo.getLocation(new BMap.Point(r.point.lng, r.point.lat), function(result){
                    if (result){
                        $("#locationShow").html("您当前的位置："+result.address);
                    }
                });
            }
            else {
                alert('failed'+this.getStatus());
            }
        });
        $("a").click(function(){
            if(fromLocation==""){
                alert("定位中，请稍后。。。");
                return false;
            }
            var toLocation = "116.12019,35.395847";//$(this).attr("locationInfo");
            window.location.href="${ctxPath}/app/gotoBins?fromLocation="+fromLocation+"&toLocation="+toLocation;
        })
    })

</script>
</html>